﻿using ParboiledSharp.parboiled.dataobjects;
using System;

namespace ParboiledSharp.parboiled.rules
{
    class Sequence : ContainerRule
    {
        public Sequence(params object[] rules)
        {
            SetRules(rules);
        }

        internal override bool Execute(Context context)
        {
            object[] rules = GetRules();
            foreach (object rule in rules)
            {
                    bool result = ExecuteRule(rule, context);
                    if (!result)
                    {
                        return false;
                    }
            }

            return true;
        }
    }
}
